<?php


namespace app\model;

use think\Model;

class BaseModel extends Model
{
    public function getList( $field = '*',$where = [], $offset = 0, $limit = 20,$orderby = 0,$groupby = 0)
    {

        $model = $this->field($field);
        if($where){
            $model = $model->where($where);
        }
        if($orderby){
            if(is_array($orderby)){
                foreach($orderby as $filed => $orderType){
                    $model = $model->orderBy($filed,$orderType);
                }
            }
        }
        if($groupby){
            $model = $model->groupBy($groupby);
        }
        if($offset){
            $model = $model->offset($offset);
        }
        if($limit){
            $model = $model->take($limit);
        }
        return $model;
    }


}